package arrays;

/**
 * @author LiangMu
 * @version \$Id: P14.java, v 0.1, 2022年12月14日 20:24 LiangMu Exp $$
 */
public class P14 {


    public void rotate(int[][] matrix) {
        int length = matrix.length;
        if (length <= 1) return;
        for (int i = 0; i < length; ++i) {
            for (int j = i + 1; j < length; ++j) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }
        int len = length / 2;
        for (int i = 0; i < length; ++i) {
            for (int j = 0; j < len; ++j) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[i][length - 1 - j];
                matrix[i][length - 1 - j] = temp;
            }
        }
    }


}
